package cn.iocoder.yudao.module.system.config;

import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer;
import cn.iocoder.yudao.module.system.repository.mybatis.domain.dept.Dept;
import cn.iocoder.yudao.module.system.repository.mybatis.domain.user.AdminUser;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * system 模块的数据权限 Configuration
 */
@Configuration(proxyBeanMethods = false)
public class DataPermissionConfiguration {

    @Bean
    public DeptDataPermissionRuleCustomizer sysDeptDataPermissionRuleCustomizer() {
        return rule -> {
            // dept
            rule.addDeptColumn(AdminUser.class);
            rule.addDeptColumn(Dept.class, "id");
            // user
            rule.addUserColumn(AdminUser.class, "id");
        };
    }

}
